#!/usr/bin/env python3

def check(x):
    digits = set(str(x))
    for mult in range(2,6+1):
        if set(str(x*mult)) != digits:
            return False
    return True
    
x = 1
while True:
    if check(x):
        print(x)
        break
    x += 1